/* eslint-disable import/no-commonjs */

const path = require('path')
const fs = require('fs')

function writeJson() {
  const env =  process.env.NODE_ENV === 'production'
  let AppId = env? 'wx78e72118da4b1f19' : 'wx78e72118da4b1f19'
  //现将json文件读出来
  let  data = fs.readFileSync(path.resolve(__dirname, '..','project.config.json'),'utf-8')
 var config = data.toString();
 config = JSON.parse(config)
 config.appid = AppId
 var str = JSON.stringify(config, '', '\t')
fs.writeFileSync(path.resolve(__dirname, '..','project.config.json'),str, 'utf-8')
console.log('----------  project.config.json修改appid成功:' + AppId + '  -------------')
}
module.exports = writeJson
